# 065 Hand Flop Game

This app turns the template into a wrist pronation/supination reaction-time game for two vibrating sensor nodes. Haptic cueing is always on because it is fundamental to the task.

Mount one sensor on the inside of the wrist and one on the outside. The app uses the quaternion from one wrist node to estimate wrist rotation angle around the `y` axis, with a built-in `90` degree frame compensation about the `y` axis. The first `2` seconds are used to calibrate the wrist neutral angle from the mean measured angle, then each cue starts only after the hand returns near neutral within `-10` to `+10` degrees and waits through a random cue delay before one node vibrates to signal the target direction.

Scoring:

- Each cue is scored by the time from cue start to first reaching the target angle threshold
- The default target is a fixed one-sided `45` degree threshold, using the sign of the cue direction
- A cue only starts once the wrist is back near `0` degrees and a random cue wait has elapsed, so the player begins from a ready position instead of being cued immediately
- Cue sequences are generated as a shuffled, balanced inside/outside list, and the app rounds the total cue count up to an even number so each direction is represented equally
- If a cue times out before the target angle is reached, the full cue duration counts against the average time score

Results workflow:

- The app can save an HTML report with cue-by-cue outcomes, summary metrics, direction-specific average reaction times, a Welch t-test comparison, and an angle trace
- The app can email results to the participant when `participant_email` is set and SMTP credentials are configured in `/persist/settings/secrets.json`
- The app can post scores to a RestDB-backed scoreboard when `post_scores` is enabled and the corresponding secrets are configured
- Participant fields for `name`, `institution`, and `email` are exposed in the app settings; email is used for sending results, while the posted score payload includes only name and institution
- Supported email secrets:
  `GMAIL.EMAIL_USER`, `GMAIL.EMAIL_APP_PASSWORD`, optional `GMAIL.SMTP_HOST`, `GMAIL.SMTP_PORT`, `GMAIL.TIMEOUT_SECONDS`
  Flat fallback keys are also accepted: `email_user`, `email_app_password`, `smtp_host`, `smtp_port`, `smtp_timeout_seconds`
- Supported scoreboard secrets:
  `HAND_FLOP_GAME.api_key`, `HAND_FLOP_GAME.db_collection`, optional `HAND_FLOP_GAME.db_url`
  Flat fallback keys are also accepted: `api_key`, `db_collection`, `db_url`
